/* eslint-disable no-shadow */
// import { login, logout, getInfo } from '@/api/user';

const state = {
  storeFormData: {
    code: '',
    patientId: '', // 提交人patientId
    identity: '', // 为谁加入
    name: '', // 姓名
    idCard: '', // 身份证
    phone: '', // 手机号
    sick: '', // 是否患病
    sickList: [], // 患病了，都有什么病
    noDisease: '', // 无疾病 0=否 1=是
    address: {
      provinceId: '',
      cityId: '',
      areaId: '',
      street: ''
    },
    sex: '',
    birthday: '',
    phoneType: '',
    machineNumber: '', // 其它联系方式
    otherPhone: ''
  },
  storeIllFormData: {
    teamOrderId: '', // 保险订单id
    applyPatientId: '', // 申请人ID
    patientId: '', // 患者id
    patientName: '', // 患者姓名
    beInHospital: '', // 是否在医院 1在 0已出院
    dead: '', // 是否死亡 1死亡 0未死亡
    hospitalName: '', // 确诊机构
    phone: '', // 手机号
    diagnose: '', // 诊断描述
    pics: [], // 确诊材料
    diseases: [] // 确诊疾病
  },
  appid: wx.getStorageSync('appid') || '',
  spareappid: '',
  sessionKey: '',
  openid: wx.getStorageSync('openid') || '',
  unionid: wx.getStorageSync('unionid') || '',
  phone: wx.getStorageSync('phone') || '',
  patientid: wx.getStorageSync('patientid') || '',
  token: wx.getStorageSync('token') || '',
  rawData: '',
  signature: '',
  hospitalid: '',
  // 服务包4 两个服务包id，name，类型
  serverPackList: [
    { name: '', id: '', type: '' },
    { name: '', id: '', type: '' }
  ],
  // 选中服务包信息
  serverPackInfo: {
    id: '', // 服务部ID
    basics: 0, // 是否为基础包: 1:是 0: 否
    title: '',
    serverId: '' // 档次ID
  },
  // 社区相关
  // 指定页面来源
  referers: '',
  // 选择的服务包id
  communityServiceId: ''
};

const mutations = {
  SET_STOREFORMDATA: (state, FormData) => {
    state.storeFormData = FormData;
  },
  SET_APPID: (state, appid) => {
    state.appid = appid;
    wx.setStorageSync('appid', appid);
  },
  SET_SESSIONKEY: (state, sessionKey) => {
    state.sessionKey = sessionKey;
    wx.setStorageSync('sessionKey', sessionKey);
  },
  SET_OPENID: (state, openid) => {
    state.openid = openid;
    wx.setStorageSync('openid', openid);
  },
  SET_UNIONID: (state, unionid) => {
    console.log('SET_UNIONID unionid:', unionid);
    state.unionid = unionid;
    wx.setStorageSync('unionid', unionid);
  },
  SET_PHONE: (state, phone) => {
    state.phone = phone;
    wx.setStorageSync('phone', phone);
  },
  SET_PATIENTID: (state, patientid) => {
    state.patientid = patientid;
    wx.setStorageSync('patientid', patientid);
  },
  SET_TOKEN: (state, token) => {
    state.token = token;
    wx.setStorageSync('token', token);
  },
  SET_RAWDATA: (state, rawData) => {
    state.rawData = rawData;
    wx.setStorageSync('rawData', rawData);
  },
  SET_SIGNATURE: (state, signature) => {
    state.signature = signature;
    wx.setStorageSync('signature', signature);
  },
  SET_STOREILLFORMDATA: (state, storeIllFormData) => {
    state.storeIllFormData = storeIllFormData;
  },
  SET_HOSPITALID: (state, hospitalid) => {
    state.hospitalid = hospitalid;
  },
  SET_SERVERPACKLIST: (state, serverPackList) => {
    state.serverPackList = serverPackList;
  },
  SET_SERVERPACKINFO: (state, serverPackInfo) => {
    state.serverPackInfo = serverPackInfo;
  },
  SET_REFERERS: (state, referers) => {
    state.referers = referers;
  },
  SET_COMMUNITYSERVICEID: (state, communityServiceId) => {
    state.communityServiceId = communityServiceId;
  }
};

const actions = {
  // user login
};

export default {
  namespaced: true,
  state,
  mutations,
  actions
};
